package com.atguigu;

import com.atguigu.service.BookService;
import com.atguigu.service.UserService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author 伟哥
 * @date 2021-04-30 23:07
 */
public class test {

    @Test
    public void testGeneric(){
        ApplicationContext ioc = new ClassPathXmlApplicationContext("applicationContext.xml");

        BookService bookService = ioc.getBean(BookService.class);
        UserService userService = ioc.getBean(UserService.class);

        bookService.save();
        userService.save();

        //bookService的类型：class com.atguigu.service.BookService
        System.out.println(bookService.getClass());
        //bookService的父类：class com.atguigu.service.BaseService
        System.out.println(bookService.getClass().getSuperclass());
        /*
        bookService的父类，带泛型：com.atguigu.service.BaseService<com.atguigu.bean.Book>

        Spring中可以利用带泛型的父类类型来确定这个子类的类型
         */
        System.out.println(bookService.getClass().getGenericSuperclass());

    }
}
